<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #btn1{
            background-color: greenyellow;
            width:100px;
            height:300px;
        }
        #btn2{
            background-color: blueviolet;
            width:100px;
            height:200px;

        }
        #btn3{
            background-color: red;
            width:100px;
            height:100px;
        }
    </style>
</head>
<body>
    <div id="btn1">
        <div id="btn2">
            <div id="btn3"></div>
        </div>
    </div>
</body>
<script>
    var btn1=document.getElementById('btn1');
    var btn2=document.getElementById('btn2');
    var btn3=document.getElementById('btn3');
    btn1.onclick=function(event){
        if(event.target==event.currentTarget){//阻止冒泡
            console.log(1);
        }
    }
    /*$('#btn1').mousedown(function(e){
        var e=event||window.event;
        event.stopPropagation;
      })
      */
    btn2.onclick=function(event){
        if(event.target==event.currentTarget){
            console.log(2);
        }
    }
    btn3.onclick=function(event){
        if(event.target==event.currentTarget){
            console.log(3);
        }
    }
</script>
</html>